<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%String path = request.getContextPath() ;%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %>
<!DOCTYPE html>
<html lang="zh-CN" >
<head>
    <c:set var="ctx" value="${pageContext.request.contextPath}" />
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>新增厂商</title>
    <jsp:include page="../../import.jsp" flush="true" />
</head>
<body class="iframeBody">
<div class="Wrapper">
    <div id="pageInTab" class="pageInTab">
        <div tabid="tabA" title="基本信息" lselected="true">
            <form id="formSet1">
                <table class="sq-formTable">
                    <tbody>
                    <tr>
                        <td class="tbLabel"><div class="label">厂商名称</div></td>
                        <td>
                            <div class="field">
                                <input name="mfrNm" id="mfrNm" type="text" class="ui-textbox" value="" validate="{required:true}">
                            </div>
                            <span class="requiredSymbol">*</span>
                        </td>
                        <td class="tbLabel"><div class="label">厂商地址</div></td>
                        <td>
                            <div class="field">
                                <input name="mfrAddr" id="mfrAddr" type="text" class="ui-textbox" value="" >
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td class="tbLabel"><div class="label">厂商传真</div></td>
                        <td>
                            <div class="field">
                                <input name="mfrFax" id="mfrFax" type="text" class="ui-textbox" value="">
                            </div>
                        </td>
                        <td class="tbLabel"><div class="label">厂商电话</div></td>
                        <td>
                            <div class="field">
                                <input name="mfrTel" id="mfrTel" type="text" class="ui-textbox" value="" validate="{mobileAndFixedPhone:true}">
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td class="tbLabel"><div class="label">联系人</div></td>
                        <td>
                            <div class="field">
                                <input name="lmNm" id="lmNm" type="text" class="ui-textbox" value="" validate="{required:true,nmcharacter:true}">
                            </div>
                            <span class="requiredSymbol">*</span>
                        </td>
                        <td class="tbLabel"><div class="label">身份证号</div></td>
                        <td>
                            <div class="field">
                                <input name="lmIdNum" id="lmIdNum" type="text" class="ui-textbox" value="" validate="{idcardno:true}">
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td class="tbLabel"><div class="label">办公电话</div></td>
                        <td>
                            <div class="field">
                                <input name="lmOfficeTel" id="lmOfficeTel" type="text" class="ui-textbox" value="" validate="{mobileAndFixedPhone:true}">
                            </div>
                        </td>
                        <td class="tbLabel"><div class="label">邮编</div></td>
                        <td>
                            <div class="field">
                                <input name="lmZipNo" id="lmZipNo" type="text" class="ui-textbox" value="" validate="{zipcode:true}">
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td class="tbLabel"><div class="label">常住地址</div></td>
                        <td>
                            <div class="field">
                                <input name="lmAddr" id="lmAddr" type="text" class="ui-textbox" value="">
                            </div>
                        </td>
                        <td class="tbLabel"><div class="label">EMAIL</div></td>
                        <td>
                            <div class="field">
                                <input name="lmEMail" id="lmEMail" type="text" class="ui-textbox" value="" validate="{email:true}">
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td class="tbLabel"><div class="label">手机号码</div></td>
                        <td>
                            <div class="field">
                                <input name="lmMp1" id="lmMp1" type="text" class="ui-textbox" value="" validate="{mobile:true}">
                            </div>
                        </td>
                        <td class="tbLabel"><div class="label">手机号码2</div></td>
                        <td>
                            <div class="field">
                                <input name="lmMp2" id="lmMp2" type="text" class="ui-textbox" value="" validate="{mobile:true}">
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td class="tbLabel">
                            <div class="label">
                                <span class="sqiconfont sqicon-tishi c_sqYellow gridTip" title="说明：厂商金融业务放款时，用于判断放款金额是否扣除贴息费用项。"></span>放款方式
                            </div>
                        </td>
                        <td align="left">
                            <div class="field">
                                <input name="payTypCd" id="payTypCd" data-value="" placeholder="请选择" ltype="combobox" validate="{required:true}">
                            </div>
                            <span class="requiredSymbol">*</span>
                        </td>
                        <td class="tbLabel"><div class="label"></div></td>
                        <td colspan="3" align="left"></td>
                    </tr>
                    <tr>
                        <td colspan="4" align="center">
                            <div class="btnsBox">
                                <span id="saveBtn1" class="sq-button sq-button-round">保存</span>
                                <input name="mId" id="mId" type="hidden" value="${id }">
                            </div>
                        </td>
                    </tr>
                    </tbody>
                </table>
            </form>
        </div>
        <div tabid="tabB" title="资料信息">
            <iframe frameborder="0" name="tabB" id="tabB" src=""></iframe>
        </div>
        <div tabid="tabC" title="授信备案">
            <iframe frameborder="0" name="tabC" id="tabC" src=""></iframe>
        </div>
        <div tabid="tabD" title="远程跟踪">
            <iframe frameborder="0" name="tabD" id="tabD" src=""></iframe>
        </div>
    </div>
</div>


<script type="text/javascript">
    var loadedTabs=[];

    $(function(){
        $("#payTypCd").ligerComboBox({
            valueField: 'key',
            textField: 'value',
        });

        $("#formSet1").ligerForm({
            validate : true
        });
        $("#formSet1").ligerForm();
        liger.get("payTypCd").setData(${payTypCdList});

        $("#saveBtn1").click(function(event) {
            var form = new liger.get("formSet1");
            if (!form.valid()) {
                $.ligerDialog.SQalert({content:LogUtils.LOG_CMM_MUST_FIX_ITEM_INFO, SQ_type: "warning"});
                return false; //验证不通过，不执行以下代码
            }
            var data = form.getData();
            data.isSpl = $('input[name="isSpl"]:checked ').val();
            var id = $("#mId").val();
            var url='<%=path%>/product/mfrInfo/add.do';
            if(id != ""){
                url = '<%=path%>/product/mfrInfo/modify.do';
                data["id"]= id;
            }
            var wait_dialog;
            $.ajax({
                type: 'post',
                dataType:'json',
                data:data,
                url: url,
                beforeSend: function(){
                    wait_dialog=$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING ,SQ_type: "waitting" });
                },
                success:function(msg){
                    wait_dialog.close();
                    if(msg.success == 1){
                        $.ligerDialog.SQalert({content:msg.info, SQ_type: "success"});
                        if(msg.data){
                            $("#mId").val(msg.data);
                        }
                        //callback回调
                        var TAB=top.mainApp.parentTab;
                        var currentTabid=TAB.getSelectedTabItemID();
                        var currentTabiframe=top.$("#"+currentTabid).get(0);
                        var callback=currentTabiframe.W2W.callback;
                        callback();
                    }else{
                        $.ligerDialog.SQalert({content:msg.info, SQ_type: "error"});
                    }
                }
            })
        })
        initTab();
        initData();
    })
    function initData(){
        var id = $("#mId").val();
        if(!id){
            return;
        }
        var _url = '<%=path%>/product/mfrInfo/getById.do';
        $.ajax({
            type: 'get',
            dataType:'json',
            data:{id:id},
            url: _url,
            success:function(msg){
                if(msg.success == 1){
                    setData(msg.data);//设置数据
                }else{
                    $.ligerDialog.SQalert({content:msg.info, SQ_type: "error"});
                }
            }
        });
    }
    //设置页面数据
    function setData(data){
        var form = liger.get("formSet1");

        $("#mfrNm").val(data.mfrNm);
        $("#mfrAddr").val(data.mfrAddr);
        $("#mfrFax").val(data.mfrFax);
        $("#mfrTel").val(data.mfrTel);
        $("#lmNm").val(data.lmNm);
        $("#lmIdNum").val(data.lmIdNum);
        $("#lmOfficeTel").val(data.lmOfficeTel);
        $("#lmZipNo").val(data.lmZipNo);
        $("#lmAddr").val(data.lmAddr);
        $("#lmEMail").val(data.lmEMail);
        $("#lmMp1").val(data.lmMp1);
        $("#lmMp2").val(data.lmMp2);
        liger.get("payTypCd").setValue(data.payTypCd);
        liger.get("payTypCd").updateStyle();
    };
    //初始化Tab页
    function initTab(){
        pageInTab = $("#pageInTab").ligerTab({
            height: 'auto',
            contextmenu: false,
            minIframeHeight: 450,
            onBeforeSelectTabItem: function (tabid) {
                var _mId = $("#mId").val();
                if(tabid!="tabA"){
                    if(!_mId){
                        top.$.ligerDialog.SQalert({content: "请确认厂商基本信息已存在", SQ_type: "warning"});
                        return false;
                    }
                }
            },
            onAfterSelectTabItem: function(tabid) {
                if (loadedTabs.indexOf(tabid)<0) {
                    var _mId = $("#mId").val();
                    if(tabid!="tabA"){
                        if(!_mId){
                            top.$.ligerDialog.SQalert({content: "请确认厂商基本信息已存在", SQ_type: "warning"});
                            return false;
                        }
                    }
                    loadedTabs.push(tabid);
                    /*switch (tabid){
                     case "tabB":
                     pageInTab.setTabItemSrc(tabid, "<%=path%>/project/prjQuatPrpsAttr/toAddPage.do?prpsCfgId="+_prpsCfgId);
                     break;
                     case "tabC":
                     pageInTab.setTabItemSrc(tabid, "<%=path%>/project/prjQuatPrpsCfgAi/toListPage.do?prpsCfgId="+_prpsCfgId);
                     break;
                     }*/
                };
                SetIframe_height();
            }
        });
    };
</script>



</body>
</html>
